-
Notifications
You must be signed in to change notification settings - Fork 1
Extend modeling of linear incidences with unknown coefficients #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The intrinsic tfunc can distribute this, right? It's just the IPO representation that can't. |
That's correct, the tfunc does it just fine. |
test/incidence.jl
Outdated
incidence = @incidence t *ᵢ u₁ | ||
@test incidence.typ === Const(0.0) | ||
@test dependencies(incidence.row) == [1 => linear_state_dependent, 2 => linear_time_dependent] | ||
@test repr(incidence) == "Incidence(f(∝t, ∝u₁))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tricky one, I think this one should probably just be f₁(t) * u₁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it should be f₁(t) * u₁ + f₂(u₁) * t
to cover, e.g., @incidence t *ᵢ u₁ + t + u₁
which has the same incidence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have enough precision to resolve f₂(u₁)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this special case we could resolve it (there is only one state, so state dependence means we depend on that single state), but this would break down as soon as we introduce more states. We'd need to track the full matrix to do that reliably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sorry the shorthand was a bit over-precise - the main suggestion is not to break symmetry here in the repr
(i.e. Incidence(f(∝t, ∝u₁))
seems better, now that I understand it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that the intent is to print time as a state coefficient, rather than state as a time coefficient. The symmetry would be broken by the fact that state is a somewhat more central as incidence information than time.
That does seem reasonable to me, but I'm also fine with the current printing.
Yeah, that's pretty much what I expected. There's various things we could do eventually, but it's fine for now. |
test/incidence.jl
Outdated
incidence = @incidence t *ᵢ u₁ | ||
@test incidence.typ === Const(0.0) | ||
@test dependencies(incidence.row) == [1 => linear_state_dependent, 2 => linear_time_dependent] | ||
@test repr(incidence) == "Incidence(f(∝t, ∝u₁))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it should be f₁(t) * u₁ + f₂(u₁) * t
to cover, e.g., @incidence t *ᵢ u₁ + t + u₁
which has the same incidence
9c41806
to
2f5ced4
Compare
aadd570
to
e7a97eb
Compare
Tests will need JuliaDiff/Diffractor.jl#304 to get Diffractor to precompile, but they all pass locally for me. |
Implements the
Incidence
linearity extension outlined in #30.This extends the two-level linearity information (linear with a known constant factor, and nonlinear) with three more, resulting in:
Float64
value).linear
).linear_state_dependent
,linear_time_dependent
).linear_time_and_state_dependent
).nonlinear
- always taints state and time dependence currently).At the moment, incidence IPO is not capable of distributing constant terms such as
(1.0 + u1) * (2.0 + u2)
, which will result in an incidence with an unknown term represented with atyp
ofFloat64
instead ofConst(2.0)
as one would expect.Another limitation is that state dependence to an unspecified variable may prevent us in certain cases from inferring which products (
mul_float
) or substitutions (apply_linear_incidence
) remain linear through multiplication with another variable that exhibits a state dependence. See the_muladd2
test which illustrates this in an IPO context. This may also taint time dependence in IPO when time is provided as argument to a callee that then treats it as a state variable.Perhaps this is acceptable, or perhaps that justifies using a (sparse) incidence matrix. @Keno feel free to suggest alternate designs if you feel that this one does not satisfy our needs.
To do:
Incidence
/Linearity
.# XXX
comments.@Incidence
macro.